package com.vhall.component.controller.interactive;

import com.vhall.component.controller.interactive.facade.QaFacade;
import com.vhall.component.entity.interactive.ListReqVo;
import com.vhall.component.entity.interactive.dto.AnswerDto;
import com.vhall.component.entity.interactive.vo.*;
import com.vhall.component.framework.common.annotation.VhallComponent;
import com.vhall.component.plugin.common.annotation.VssTokenAuth;
import com.vhall.component.plugin.common.support.VssToken;
import com.vhall.component.plugin.common.support.VssTokenThreadLocal;
import com.vhall.component.service.interactive.QaService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

/**
 * @author xianglei
 * @date 2021/7/15 16:17
 */
@VssTokenAuth
@VhallComponent
public class QaController implements QaFacade {

    @Autowired
    private QaService qaService;

    @Override
    public QuestionRspVo create(CreateReqVo reqVo) {
        VssToken token = VssTokenThreadLocal.getToken();
        reqVo.setAccountId(token.getThirdPartyUserId());
        return qaService.create(reqVo);
    }

    @Override
    public Boolean show(ShowReqVo reqVo) {
        VssToken token = VssTokenThreadLocal.getToken();
        reqVo.setAccountId(token.getThirdPartyUserId());
        return qaService.show(reqVo);
    }

    @Override
    public AnswerDto answer(AnswerReqVo reqVo) {
        VssToken token = VssTokenThreadLocal.getToken();
        reqVo.setAccountId(token.getThirdPartyUserId());
        return qaService.answer(reqVo);
    }

    @Override
    public Map<String, Object> lists(ListReqVo reqVo) {
        VssToken token = VssTokenThreadLocal.getToken();
        reqVo.setAccountId(token.getThirdPartyUserId());
        return qaService.lists(reqVo);
    }

    @Override
    public Boolean switchs(SwitchReqVo reqVo) {
        VssToken token = VssTokenThreadLocal.getToken();
        reqVo.setAccountId(token.getThirdPartyUserId());
        return qaService.switchs(reqVo);
    }

    @Override
    public QuestionRspVo deal(DealReqVo reqVo) {
        VssToken token = VssTokenThreadLocal.getToken();
        reqVo.setAccountId(token.getThirdPartyUserId());
        return qaService.deal(reqVo);
    }

    @Override
    public AnswerRspVo dealAnswer(DealAnswerReqVo reqVo) {
        VssToken token = VssTokenThreadLocal.getToken();
        reqVo.setAccountId(token.getThirdPartyUserId());
        return qaService.dealAnswer(reqVo);
    }

    @Override
    public Boolean switchAlsoAsk(SwitchReqVo reqVo) {
        VssToken token = VssTokenThreadLocal.getToken();
        reqVo.setAccountId(token.getThirdPartyUserId());
        return qaService.switchAlsoAsk(reqVo);
    }

    @Override
    public QuestionRspVo toggleAlsoAsk(ToggleAlsoAskReqVo reqVo) {
        VssToken token = VssTokenThreadLocal.getToken();
        reqVo.setAccountId(token.getThirdPartyUserId());
        return qaService.toggleAlsoAsk(reqVo);
    }
}
